package com.gosophia.conference.action.confPrepare;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.oa.action.JudgeCurrentUndertaker;
import com.gosophia.springsecurity.UserDetailsImpl;
import com.gosophia.taskManagement.dto.JobDTO;
import com.gosophia.taskManagement.ws.TaskManagementWebService;
import com.gosophia.userManagement.dto.UserInfoDTO;
import com.opensymphony.xwork2.ActionSupport;
/**
 * 进入会务准备页面
 * @author wangxinbing
 * @since  2011-3-25
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Component("ToConfPreparePageAction")
@Scope("prototype")
public class ToConfPreparePageAction extends BaseSupportAction {
    //jobId
	private Long jobId;
	
	private String userName;
	
	private boolean ifCofirm;
	
	@Autowired
	private TaskManagementWebService taskManagementWebService;
	@Autowired
	private JudgeCurrentUndertaker judgeCurrentUndertaker;
	public String _execute() throws Exception{
		//判断是否匹配,如果不匹配转到异常页面
        judgeCurrentUndertaker.judgeOperationAuthority(jobId);
		UserDetailsImpl userDetails = (UserDetailsImpl) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserInfoDTO creatorDTO = userDetails.getUserAccountDTO().getUserInfoDTO();
        userName = creatorDTO.getUserName();
        JobDTO confP = taskManagementWebService.findJobDetailByJobId(jobId);
        JobDTO noticTrans = taskManagementWebService.findJobByMissionIdAndJobType(confP.getMissionDTO().getMissionId(),"正式通知发送");
        if(noticTrans == null){
        	ifCofirm = false;
        }else if(noticTrans.getActualEndTime() == null){
        	ifCofirm = false;
        }else if(noticTrans.getActualEndTime() !=null){
        	ifCofirm = true;
        }
		return SUCCESS;
	}
	public Long getJobId() {
		return jobId;
	}
	public void setJobId(Long jobId) {
		this.jobId = jobId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public boolean isIfCofirm() {
		return ifCofirm;
	}
	public void setIfCofirm(boolean ifCofirm) {
		this.ifCofirm = ifCofirm;
	}
}
